﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>Index</title>
    <script src="~/lib/jquery/1.12.4/jquery.min.js"></script>
    <script src="~/lib/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <link href="~/lib/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/css/framework-font.css" rel="stylesheet" />
    <link href="~/css/framework-theme.css" rel="stylesheet" />
    <link href="~/lib/select2/select2.min.css" rel="stylesheet" />
    <script src="~/lib/select2/select2.min.js"></script>
    <link href="~/lib/jqgrid/5.3.0/css/ui.jqgrid-bootstrap.css" rel="stylesheet" />
    <script src="~/lib/jqgrid/5.3.0/js/jquery.jqGrid.js"></script>
    <script src="~/lib/jqgrid/5.3.0/i18n/grid.locale-cn.js"></script>
    <link href="~/css/framework-ui.css" rel="stylesheet" />
    <script src="~/js/framework-ui.js"></script>
</head>
<body>
    <div class="topPanel">
        <div class="toolbar">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
            <div class="btn-group">
                
            </div>
            <div class="operate">
                <ul class="nav nav-pills">
                    <li class="first">已选中<span>1</span>项</li>
                </ul>
                <a href="javascript:;" class="close"></a>
            </div>
            <script>$('.toolbar').authorizeButton()</script>
        </div>
        <div class="search">
            <table>
                <tr>
                    <td>
                        <div class="input-group">
                            <input id="txt_keyword" type="text" class="form-control" placeholder="用户名" style="width: 200px;">
                            <span class="input-group-btn">
                                <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                            </span>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="gridPanel">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
    <script>
        $(function () {
            gridList();
        })
        function gridList() {
            var $gridList = $("#gridList");
            $gridList.dataGrid({
                url: "/SystemSecurity/LoginLog/GetGridJson",
                height: $(window).height() - 128,
                //rowNum: 20,	
                colModel: [
                    { label: '主键', name: 'Id', hidden: true },
                    { label: '用户名', name: 'UserName', width: 100, align: 'center' },
                    {
                        label: '操作类型', name: 'OperateType', width: 100, align: 'center',
                        formatter: function (cellvalue, options, rowObject) {
                            if (cellvalue == 'Login') {
                                return '<span class=\"label label-success\">登入</span>';
                            }
                            else if (cellvalue == 'Logout') {
                                return '<span class=\"label label-warning\">登出</span>';
                            }
                        }
                    },

                    { label: '操作时间', name: 'OperateTime', width: 100, align: 'center' },
                    {
                        label: '操作结果', name: 'OperateResult', width: 100, align: 'center',
                        formatter: function (cellvalue, options, rowObject) {
                            if (cellvalue == true) {
                                return '<span class=\"label label-success\">登录成功</span>';
                            }
                            else if (cellvalue == false) {
                                return '<span class=\"label label-danger\">登录失败</span>';
                            }
                        }
                    },
                    {
                        label: 'IP地址', name: 'IpAddress', width: 100, align: 'left',
                        formatter: function (cellvalue, options, rowObject) {
                            if (cellvalue == '127.0.0.1' || cellvalue == '::1' || cellvalue == 'localhost') {
                                return cellvalue + '&nbsp&nbsp' + '本地';
                            }
                            else {
                                return cellvalue + '&nbsp&nbsp' + rowObject.IpAddressLocation;
                            }
                        }
                    },
                    { label: '备注', name: 'Description', width: 200, align: 'left' }
                ],
                pager: "#gridPager",
                sortname: 'CreatorTime desc',
                viewrecords: true
            });
            $("#btn_search").click(function () {
                $gridList.jqGrid('setGridParam', {
                    postData: { keyword: $("#txt_keyword").val() },
                }).trigger('reloadGrid');
            });
        }
    </script>
</body>
</html>
